import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router);

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [


  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [{
      path: 'home',
      name: 'home',
      component: () => import('@/views/home/home'),
      meta: { title: 'PVE衍天宗计算器', icon: 'dashboard' }
    }]
  },

  {
    path: '/pvp',
    component: Layout,
    hidden:true,
    children: [{
      path: 'pvp',
      name: 'pvp',
      component: () => import('@/views/home/pvp'),
      meta: { title: 'PVP衍天宗计算器', icon: 'table' }
    }]
  },
  {
    path: '/pve',
    component: Layout,
    meta: { title: '衍天PVE笔记', icon: 'excel',},
    children: [
      {
        path: 'pve',
        name: 'pve',
        component: () => import('@/views/home/pve/pve'),
        meta: { title: '前言' }
      },
      {
        path: 'miji',
        name: 'miji',
        component: () => import('@/views/home/pve/miji'),
        meta: { title: '秘籍' }
      },
      {
        path: 'qixue',
        name: 'qixue',
        component: () => import('@/views/home/pve/qixue'),
        meta: { title: '流派介绍' }
      },
      {
      path: 'skill',
      name: 'skill',
      component: () => import('@/views/home/pve/skill'),
      meta: { title: '技能奇穴介绍' }
    },
      {
        path: 'settings',
        name: 'settings',
        component: () => import('@/views/home/pve/settings'),
        meta: { title: '插件设置' }
      },
      {
        path: 'method',
        name: 'method',
        component: () => import('@/views/home/pve/method'),
        meta: { title: '输出循环' }
      },
      {
        path: 'hong',
        name: 'hong',
        component: () => import('@/views/home/pve/hong'),
        meta: { title: '自用宏分享' }
      },
      {
        path: 'zhuangbei',
        name: 'zhuangbei',
        component: () => import('@/views/home/pve/zhuangbei'),
        meta: { title: '配装推荐' }
      },
      {
        path: 'guide',
        name: 'guide',
        component: () => import('@/views/home/pve/guide'),
        meta: { title: '计算器用法' }
      },
      {
        path: 'dmd',
        name: 'dmd',
        hidden:true,
        component: () => import('@/views/home/pve/dmd'),
        meta: { title: '达摩洞个人心得' }
      },
      {
        path: 'sl',
        name: 'sl',
        hidden:true,
        component: () => import('@/views/home/pve/sl'),
        meta: { title: '试炼之地打法推荐' }
      },
      {
        path: 'jiqiao',
        name: 'jiqiao',
        hidden:true,
        component: () => import('@/views/home/pve/jiqiao'),
        meta: { title: '不是太正经的进阶技巧' }
      },
    ]
  },
  {
    path: '/acc',
    component: Layout,
    children: [{
      path: 'acc',
      name: 'acc',
      component: () => import('@/views/home/acc'),
      meta: { title: '加速阈值', icon: 'education' }
    }]
  },
  {
    path: '/test',
    component: Layout,
    children: [{
      path: 'test',
      name: 'test',
      component: () => import('@/views/home/test'),
      meta: { title: '模块化测试', icon: 'guide' }
    }]
  },
  {
    path: '/analyse',
    component: Layout,
    hidden:true,
    children: [{
      path: 'analyse',
      name: 'analyse',
      component: () => import('@/views/home/analyse'),
      meta: { title: '出警模块(测试版)', icon: 'el-icon-phone' }
    },
      {
        path: 'ana_detail',
        name: 'ana_detail',
        hidden:true,
        component: () => import('@/views/home/ana_detail'),
        meta: { title: '战斗复盘', icon: 'el-icon-phone' }
      },
    ]
  },


  {
    path: 'https://support.qq.com/products/296701',
    component: Layout,
    meta: { title: '反馈', icon: 'bug' }
  },
  {
    path: '/choujiang',
    component: Layout,
    hidden:false,
    children: [{
      path: '',
      name: 'choujiang',
      component: () => import('@/views/home/choujiang'),
      meta: { title: '抽奖', icon: 'education' }
    }]
  },
  {
    path: '/pwd',
    component: Layout,
    hidden:true,
    children: [{
      path: 'pwd',
      name: 'pwd',
      component: () => import('@/views/home/pwd'),
      meta: { title: '密码簿', icon: 'education' }
    }]
  },
  {
    path: 'https://www.j3pz.com/',
    component: Layout,
    meta: { title: '胖叔叔配装器', icon: 'j3pz' }
  },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true },


]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
